home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
A.D. Software
/
OOFILE
/
OOFILE AppMaker
/
FileAndFind
/
Pre-built version, as generated
/
CFileAndFindDoc.cp
< prev
next >
Wrap
Text File
|
1996-03-21
|
4KB
|
202 lines
// CFileAndFindDoc.cp -- Document methods
// Created 21/3/96 12:09 by AppMaker
#include "CFileAndFindDoc.h"
#include "FileAndFind_OOFILE.h"
#include "CEditArticle.h"
#include "CEditArticle.h"
#include "CListArticles.h"
#include "CmdCodes.h"
#include <LFile.h>
#include <LPlaceHolder.h>
#include <LPrintout.h>
#include <LWindow.h>
#include <UWindows.h>
#include <String_Utils.h>
const ResIDT prto_PrintView = 201;
const ResIDT STRx_Untitled = 128;
// ---------------------------------------------------------------------------
// • CFileAndFindDoc
// ---------------------------------------------------------------------------
CFileAndFindDoc::CFileAndFindDoc(
LCommander *inSuper)
: LSingleDoc(inSuper)
, mData(0)
, mArticles(0)
{
}
// ---------------------------------------------------------------------------
// • ~CFileAndFindDoc
// ---------------------------------------------------------------------------
// Destructor
//
CFileAndFindDoc::~CFileAndFindDoc()
{
delete mData;
delete mArticles;
}
//----------
void
CFileAndFindDoc::newFile()
{
FSSpec fileSpec;
if (AskSaveAs(fileSpec, true)) {
MakeDatabaseObjects();
mData->newConnection(OOF_MacString(fileSpec.name));
CompleteOpenFile(&fileSpec);
}
}
//----------
void
CFileAndFindDoc::openFile(
FSSpec *inFileSpec)
{
MakeDatabaseObjects();
mData->openConnection(OOF_MacString(inFileSpec->name));
CompleteOpenFile(inFileSpec);
}
// ---------------------------------------------------------------------------
// • DoPrint
// ---------------------------------------------------------------------------
// Print the contents of the Document
void
CFileAndFindDoc::DoPrint()
{
LPrintout *thePrintout = LPrintout::CreatePrintout(prto_PrintView);
LPlaceHolder *textPlace = (LPlaceHolder *)
thePrintout->FindPaneByID('TBox');
//! textPlace->InstallOccupant(mTextView, atNone);
thePrintout->DoPrintJob();
delete thePrintout;
}
//----------
void
CFileAndFindDoc::DoAddArticleLocation ()
{
}
//----------
void
CFileAndFindDoc::DoDelArticleLocation ()
{
}
//----------
Boolean
CFileAndFindDoc::ObeyCommand(
CommandT inCommand,
void *ioParam)
{
Boolean cmdHandled = true;
switch (inCommand) {
// +++ Add cases here for the commands you handle
// Remember to add same cases to FindCommandStatus below
// to enable/disable the menu items for the commands
case cmdAddArticleLocation:
DoAddArticleLocation ();
break;
case cmdDelArticleLocation:
DoDelArticleLocation ();
break;
default:
cmdHandled = LSingleDoc::ObeyCommand(inCommand, ioParam);
break;
}
return cmdHandled;
}
//----------
void
CFileAndFindDoc::FindCommandStatus(
CommandT inCommand,
Boolean &outEnabled,
Boolean &outUsesMark,
Char16 &outMark,
Str255 outName)
{
outUsesMark = false;
switch (inCommand) {
// +++ Add cases here for the commands you handle
case cmdAddArticleLocation:
outEnabled = true;
break;
case cmdDelArticleLocation:
outEnabled = true;
break;
default:
LSingleDoc::FindCommandStatus(inCommand, outEnabled,
outUsesMark, outMark, outName);
break;
}
}
//----------
void
CFileAndFindDoc::MakeDatabaseObjects()
{
// MUST TAKE PLACE BEFORE newConnection or openConnection
// you can't define dbTables after opening the connection
// Note if these were defined as part of CFIleAndFindDoc, instead of being
// 'newed' heap-based objects, this method would not be necessary
mData = new dbConnect_ctree;
// create all database tables
mArticles = new CdbArticles;
// change types of files created by c-tree (given modification to ctclib.c)
ctMacCreator = kSignature;
ctMacType = kFileType;
}
//----------
void
CFileAndFindDoc::CompleteOpenFile(
FSSpec *inFileSpec)
{
// can now make the factories for our database editing windows and dialogs
// which require us to have constructed the database objects
AdoptAddDialogFactory(new CEditArticleFactory(this, mArticles));
AdoptEditDialogFactory(new CEditArticleFactory(this, mArticles));
AdoptBrowseWindowFactory(new CListArticlesFactory(this, mArticles));
mWindow = MakeBrowser();
if (mWindow != nil) {
mWindow->SetDescriptor (inFileSpec->name);
}
mIsSpecified = true;
}